
import 'music_center_platform_interface.dart';

class MusicCenter {

  /// Constructs a singleton instance of [SerialPort].
  ///
  /// [SerialPort] is designed to work as a singleton.
  // When a second instance is created, the first instance will not be able to listen to the
  // EventChannel because it is overridden. Forcing the class to be a singleton class can prevent
  // misuse of creating a second instance from a programmer.
  factory MusicCenter() {
    _singleton ??= MusicCenter._();
    return _singleton!;
  }

  MusicCenter._();

  static MusicCenter? _singleton;

  static MusicCenterPlatform get _platform{
    return MusicCenterPlatform.instance;
  }


  Future<String?> getPlatformVersion() {
    return _platform.getPlatformVersion();
  }

  Future<bool> switchMusicOn() {
    return _platform.switchMusicOn();
  }

  Future<bool> isMusicOn() {
    return _platform.isMusicOn();
  }

  Future<bool> nextMusic() {
    return _platform.nextMusic();
  }

  Future<bool> lastMusic() {
    return _platform.lastMusic();
  }

  Stream<bool> get musicOn => _platform.musicOn;
}
